package fr.inserm.u674.chcdbweb.model.DTO;

/**
 * This class represents a Data Transfer Object for an User. This DTO can be used troughout all
 * layers, the data layer, the controller layer and the view layer
 * 
 * @author Thomas Burguiere
 */
public class User {
	private String initials;
	private String firstName;
	private String lastName;

	public User() {
	}

	public User(String initials) {
		this.initials = initials;
	}

	public User(String initials, String firstName, String lastName) {
		this.initials = initials;
		this.firstName = firstName;
		this.lastName = lastName;
	}

	public String getInitials() {
		return initials;
	}

	public void setInitials(String initials) {
		this.initials = initials;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof User && ((User) obj).getInitials().equals(initials)) return true;
		return false;
	}

	@Override
	public int hashCode() {
		if (initials != null)
			return this.getClass().hashCode() + initials.hashCode();
		else
			return super.hashCode();
	}

	@Override
	public String toString() {
		return firstName + " " + lastName + " (" + initials + ")";
	}
}
